package com.ruoyi.web.controller.process;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.process.domain.WorkMachseeding;
import com.ruoyi.process.service.IWorkMachseedingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机器播种管理Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/process/machseeding")
public class WorkMachseedingController extends BaseController
{
    @Autowired
    private IWorkMachseedingService workMachseedingService;

    /**
     * 查询机器播种管理列表
     */
    @PreAuthorize("@ss.hasPermi('process:machseeding:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkMachseeding workMachseeding)
    {
        startPage();
        List<WorkMachseeding> list = workMachseedingService.selectWorkMachseedingList(workMachseeding);
        return getDataTable(list);
    }

    /**
     * 导出机器播种管理列表
     */
    @PreAuthorize("@ss.hasPermi('process:machseeding:export')")
    @Log(title = "机器播种管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WorkMachseeding workMachseeding)
    {
        List<WorkMachseeding> list = workMachseedingService.selectWorkMachseedingList(workMachseeding);
        ExcelUtil<WorkMachseeding> util = new ExcelUtil<WorkMachseeding>(WorkMachseeding.class);
        return util.exportExcel(list, "机器播种管理数据");
    }

    /**
     * 获取机器播种管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('process:machseeding:query')")
    @GetMapping(value = "/{workMachseedingId}")
    public AjaxResult getInfo(@PathVariable("workMachseedingId") Long workMachseedingId)
    {
        return AjaxResult.success(workMachseedingService.selectWorkMachseedingById(workMachseedingId));
    }

    /**
     * 新增机器播种管理
     */
    @PreAuthorize("@ss.hasPermi('process:machseeding:add')")
    @Log(title = "机器播种管理", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type= InjectType.Insert)
    public AjaxResult add(@RequestBody WorkMachseeding workMachseeding)
    {
        return toAjax(workMachseedingService.insertWorkMachseeding(workMachseeding));
    }

    /**
     * 修改机器播种管理
     */
    @PreAuthorize("@ss.hasPermi('process:machseeding:edit')")
    @Log(title = "机器播种管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type= InjectType.Update)
    public AjaxResult edit(@RequestBody WorkMachseeding workMachseeding)
    {
        return toAjax(workMachseedingService.updateWorkMachseeding(workMachseeding));
    }

    /**
     * 删除机器播种管理
     */
    @PreAuthorize("@ss.hasPermi('process:machseeding:remove')")
    @Log(title = "机器播种管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{workMachseedingIds}")
    public AjaxResult remove(@PathVariable Long[] workMachseedingIds)
    {
        return toAjax(workMachseedingService.deleteWorkMachseedingByIds(workMachseedingIds));
    }
}
